package com.hmy.cornpestdet.mapper;

import com.hmy.cornpestdet.pojo.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface UserLoginRegisterMapper {

    @Select("select * from user where uid = #{uid}")
    public User getUserByUid(int uid);

    @Select("select * from user where username = #{username}")
    public User getUserByUsername(String username);

    @Select("select * from user where username = #{username} and `character` = #{character}")
    public User getUserByUsernameAndCharacter(String username,int character);

    @Select("select * from user where phone_number = #{phoneNumber}")
    public User getUserByPhoneNumber(String phoneNumber);

    public List<User> getAllUser();

    @Insert("insert into user values (#{uid},#{username},#{password},#{phoneNumber},#{character},#{registerDate},#{province});")
    @Options(useGeneratedKeys=true, keyProperty="uid", keyColumn="uid")
    public int insertUser(User user);
}
